<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <base href="http://localhost:8080/file_upload_war_exploded/">
    <link rel="stylesheet" href="static/css/bootstrap.css">
    <style>
        .table th, .table td {
            padding: 0.8rem !important;
            font-size: 12px;
        }
    </style>
</head>
<body>
<div class="container col-8">
    <table class="table table-hover">
        <thead>
        <tr>
            <th scope="col">编号</th>
            <th scope="col">账号</th>
            <th scope="col">用户名</th>
            <th scope="col">邮箱</th>
            <th scope="col">头像文件</th>
            <th scope="col">操作</th>
        </tr>
        </thead>
        <tbody>

        </tbody>
    </table>
</div>

<script src="static/js/jquery-3.5.1.js"></script>
<script !src="">
    $(function () {
        $.ajax({
            url: "user/getAll",
            type: "POST",
            dataType: "json",
            success: function (data) {
                console.log(data);
                $("tbody").empty();
                if (data.length > 0) {
                    $.each(data, function (index, item) {

                        if (item.uEmail == null || item.uEmail == "") {
                            item.uEmail = "<font color='red'>未设置邮箱</font>";
                        }

                        if (item.imgPath == null) {
                            item.imgPath = "<font color='red'>未设置头像</font>"
                        }
                        $("tbody").append("<tr><th scope='row'>" + item.id + "</th><td>" + item.uUser + "</td><td>" + item.uName + "</td><td>" + item.uEmail + "</td><td>" + item.imgPath + "</td><td><a href='user/updatePage/" + item.id + "'>编辑</a></td></tr>")
                    })
                }
            },
            error: function (e) {
                alert("获取数据失败!" + e.toString())
            }
        })
    })
</script>
</body>
</html>
